ACTOR Revolver2 : BrutalWeapon
{
	Weapon.SelectionOrder 1300
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip3"
	Weapon.AmmoType2 "RevolverAmmo"
	Inventory.PickupMessage "You got the Shotvolver! Say farewell to your wrists. (Slot 2)"
    Inventory.PickupSound "REVOHAM"
	Obituary "$OB_MPSHOTGUN"
    AttackSound "None"
    +WEAPON.NOALERT
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.CHEATNOTWEAPON
	Scale 0.6
	Tag "Revolver"
	Inventory.ForbiddenTo Sorcerer, Paladin, Corvus
	States
	{
		
    Spawn:
		REVP A -1
		Stop
    	
	Select:
		REVO A 0 A_Giveinventory("GoSpecial",1)
		REVO A 0 A_TakeInventory("Revolver", 1)
		REVO AAAAAA 1 A_Raise

	SelectAnimation:
        TNT1 AAAA 0 A_JumpIfInventory("GoFatality", 1, "Steady")
        REVO LMN 1
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 1
		REVO A 0 A_GunFlash

	Ready3:	
	ReadyLoop:
	Ready:
		TNT1 A 0 A_SetCrosshair(0)
        REVO A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        REVO A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        REVO A 0 A_JumpIfInventory("Reloading",1,"Reload")
		REVO A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Unloading",1,"Unload")
		REVO A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
	OkToFire:
		REVO A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		REVO A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
        Goto Ready
		

	
	Deselect:
		REVO A 0
		REVO A 0 A_Takeinventory("Zoomed",1)
		REVO A 0 A_TakeInventory("TossGrenade", 1)
		REVO A 0 A_Takeinventory("ADSmode",1)
		REVO A 0 A_Takeinventory("UseShotgunStrap",1)
        REVO A 0 A_ZoomFactor(1.0)
		REVO A 1 A_Lower
		Wait

		
    Fire:
        REVO A 0 A_Takeinventory("Reloading",1)
        REVO A 0 A_JumpIfInventory("RevolverAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
		REVO B 1
		REVO A 0 A_ZoomFactor(0.9)
        REVO A 0 A_AlertMonsters
		REVO A 0 A_firebullets (0,0,1,40,"shotpuff",FBF_NORANDOM,100)
        REVO A 0 A_PlaySound("REVOFIR", 1)
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        REVO A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 AAAAAAAAAAAAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-12,12), 0, -1, 0, 0, random(-9,9))
		TNT1 AAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles2", random(-12,12), 0, -1, 0, 0, random(-9,9))
		TNT1 A 0 A_FireCustomMissile("DecorativeTracer", 0, 0, 0, -12, 0, 0)
		REVO A 0 A_Takeinventory("RevolverAmmo",1)
		TNT1 A 0 A_FireBullets(0.5, 0.5, -1, random(120,210), "ShotgunPuff", FBF_NORANDOM)
		//TNT1 A 0 A_FireCustomMissile("HeavyRifleProjectile", 0, 1, 0, -6)
		//REVO A 0 A_FireBullets (1, 1, 1, 100, "ShotgunPuff2", FBF_NORANDOM)
		REVO A 0 A_SetPitch(pitch-10)
		REVO CD 1 BRIGHT A_SetPitch(-3.0 + pitch)
		REVO A 0 A_SetPitch(-2.0 + pitch)
		REVO A 0 A_ZoomFactor(1.0)
		REVO E 1 A_SetPitch(+4.0 + pitch)
		REVO FG 1 A_SetPitch(+2.0 + pitch)
		REVO H 1 A_SetPitch(+1.5 + pitch)
		REVO IJK 1 A_SetPitch(pitch+1.0)
		REVO KKKK 1 A_SetPitch(pitch+0.5)
		REVO LMN 1 A_SetPitch(pitch+0.5)
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 1 A_SetPitch(pitch+0.5)
		Goto Ready3

    ReloadWithNoAmmoLeft:
    Reload:
	    REVO A 0
		REVO A 0 A_TakeInventory("Reloading", 1)
		REVO A 0 A_JumpIfInventory("Clip3", 1, 2)
		Goto NoAmmo
		REVO A 0
	    REVO A 0 A_Takeinventory("Zoomed",1)
        REVO A 0 A_ZoomFactor(1.0)
		REVO A 1 A_WeaponReady
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"OkToFire")
		REVO A 0 A_JumpIfInventory("RevolverAmmo", 1, "ReloadNormally")//Check if there is a shell in the chamber
	
	ReloadNormally:	
        REVO A 0 A_JumpIfInventory("Clip3",1,1)//If there is no reserve ammo, don't reload, go back to Ready
        Goto Ready
		REVO A 0 A_JumpIfInventory("TurboReload", 1, "TurboReload")//Check if reloads are disabled.
		REVR B 0 A_GiveInventory ("Pumping", 1)
		REVR ABCDEEDCBA 1
		TNT1 A 0 A_PLaySound("RELO1", 4)
        REVR FGHIJJJ 1
		REVR KLM 1
		REVR M 4
	 InsertingShells:
		REVO A 0
		REVO A 0 A_JumpIfInventory("Clip3",1,2)//if there are no more reserve shells, finish reload.
        Goto FinishedInsertingShells
		REVO A 0
		REVO A 0 A_GiveInventory ("Pumping", 1)
		SSHR A 0 A_TakeInventory("Reloading", 1)
		TNT1 A 0 A_FireCustomMissile("HeavyRifleCaseSpawn",0,0,-10, -20)
        REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishedInsertingShells")
        REVO A 0 A_Giveinventory("RevolverAmmo",1)
		REVO A 0 A_Takeinventory("Clip3",1)
        
	InsertShellAnimation:	
		REVO A 0
        TNT1 A 0 A_PlaySound("insertrev")
		REVR M 1 Offset(0, 30)
		REVR M 1 Offset(0, 28)
		REVR M 1 Offset(0, 30)
		REVR M 1 Offset(0, 32)
        REVR M 4 A_WeaponReady(WRF_NOBOB)
        SSHR A 0 A_JumpIfInventory("Reloading", 1, "FinishedInsertingShells")
        REVO A 0 A_JumpIfInventory("Kicking",1,"DoKickReloading")
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishedInsertingShells")//If there are 8+1 shells, stop it immediately
        Goto InsertingShells
	
		
	FinishedInsertingShells:
		REVO A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_PLaySound("RELO2", 4)
		REVR JIHGFAEDCBA 1
		REVO K 4
		REVO LMN 1
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 1
		REVO A 0 A_Takeinventory("Reloading",1)
		Goto Ready
		
	
	 TurboReload:
		SHSS BC 0
	TurboBullets:	
		REVO A 0
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishTurboReload")
        REVO A 0 A_JumpIfInventory("Clip3",1,3)
        Goto FinishTurboReload
        TNT1 AAAA 0
        REVO A 0 A_Giveinventory("RevolverAmmo",1)
		REVO A 0 A_Takeinventory("Clip3",1)
		Goto TurboBullets
	FinishTurboReload:
		REVO A 1 A_Refire
		Goto Ready3

		
	AltFire:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("RevolverChangeAmmo", 1)
		
	Unload:
		REVO A 1
		REVO A 0 A_ZoomFactor(1.0)
		REVO A 0 A_Takeinventory("Unloading",1)
		REVO A 0 A_Takeinventory("ADSmode",1)
		REVO A 0 A_Takeinventory("Zoomed",1)
        REVO A 0 A_JumpIfInventory("RevolverAmmo",1,3)
		REVO A 0 A_SetCrosshair(41)
        Goto FinishUnload
        TNT1 AAA 0
		REVO A 0 A_Takeinventory("Zoomed",1)
		REVO A 0 A_GiveInventory ("Pumping", 1)
		REVO A 0 A_Takeinventory("Unloading",1)
		REVR ABCDEEDCBA 1
		TNT1 A 0 A_PLaySound("RELO1", 4)
        REVR FGHIJJJ 1
		REVR KLM 1
		REVR M 4
		
	RemoveBullets:
		TNT1 AAAA 0
		REVO A 0 A_JumpIfInventory("RevolverAmmo",1,3)
		Goto FinishUnload
        TNT1 AAAAAA 0
		REVO A 0 A_Takeinventory("RevolverAmmo",1)
		REVO A 0 A_Giveinventory("Clip3",1)
		
		REVR M 1 Offset(0, 30)
		REVR M 1 Offset(0, 28)
		REVR M 1 Offset(0, 30)
		REVR M 1 Offset(0, 32)
		Goto RemoveBullets

	FInishUnload:
		TNT1 A 0 
		TNT1 A 0 A_JumpIfInventory("RevolverChangeAmmo", 1, "ChangeAmmo")
		REVO A 0 A_Takeinventory("Unloading",1)
		Goto OkToFire	
		
	ChangeAmmo:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("RevolverChangeAmmo", 1)
		TNT1 A 0 A_GiveInventory("Revolver")
		TNT1 A 0 A_GiveInventory("Reloading", 1)
		TNT1 A 0 A_SelectWeapon("Revolver")
		Goto Ready	
		
		
	DoKickReloading:
		NULL A 0 A_JumpIf (momZ > 0, "AirKick")
		NULL A 0 A_JumpIf (momZ < 0, "AirKick")
        REVO A 0 A_PlaySound("KICK")
		REVO A 0 SetPlayerProperty(0,1,0)
		KICK BCD 1
		RIFF A 0 A_FireCustomMissile("KickAttack", 0, 0, 0, -7)
        KICK H 3
		KICK A 0 A_Takeinventory("Kicking",1)
		KICK I 1
		KICK GFEDCBA 1 
		RIBA A 0 A_Takeinventory("Kicking",1)
		REVO A 0 SetPlayerProperty(0,0,0)
		Goto InsertingShells
		
	Steady:
		TNT1 A 1
		Goto Ready
		
		

	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVO A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		RIFG A 0 A_JumpIfInventory("Clip3",1,"Reload")
		RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
		Goto Ready3
			
	}
}


